#include "..\CookHeader.h"

int SIZE;
Array <string> stack;
int top = -1;

bool isStackEmpty() { 
	if (top == -1)
		return true;
	else
		return false;
}

bool isStackFull() {   
	if (top >= SIZE - 1)
		return true;
	else
		return false;
}

void push(string data) {   
	if (isStackFull()) {
		return;
	}
	top++;
	stack[top] = data;
}

string pop() {   
	if (isStackEmpty()) {
		return "None";
	}
	string data = stack[top];
	stack[top] = "None";
	top--;
	return data;
}

int main() {
	SIZE = 100;
	for (int i = 0; i < SIZE; i++)
		stack.push_back("None");

	FILE* rFp = fopen("C:\\CookDataC\\indian.txt", "r");
	char str[100];

	println("-----  -----");
	while (feof(rFp) == 0) {
		fgets(str, 100, rFp);
		push((string)str);
		cout << str;
	}
	fclose(rFp);

	println(endl);
	println("----- Ųٷ ó  -----");
	while (true) {
		string line = pop();
		if (line == "None")
			break;

		Array <string> miniStack; //      
		for (int i = 0; i < len(line); i++)
			miniStack.push_back("");
		int miniTop = -1;

		for (int i = 0; i < len(line); i++) {
			string ch = line.substr(i, 1); //  ھ 
			miniTop++;
			miniStack[miniTop] = ch;
		}
		while (true) {
			if (miniTop == -1)
				break;
			string ch = miniStack[miniTop];
			miniTop--;
			cout << ch;
		}
	}
}